<script language="JavaScript">
    <!--
    $(function () {

        $('input[level=1]').click(function () {
            var inputs = $(this).parents('.app').find('input');
            if ($(this).prop('checked')) {
                inputs.prop('checked', 'checked');
            } else {
                inputs.removeAttr('checked');
            }

        });

        $('input[level=2]').click(function () {
            var inputs = $(this).parents('dl').find('input');
            if ($(this).prop('checked')) {
                inputs.prop('checked', 'checked');
                var inputParent = $(this).parents('.app').find('p>input');
                inputParent.prop('checked', 'checked');
            } else {
                inputs.removeAttr('checked');
            }

        });

        $('input[level=3]').click(function () {
            var inputs = $(this).parents('dl').find('dt>input');
            if ($(this).prop('checked')) {
                inputs.prop('checked', 'checked');
                var inputParent = $(this).parents('.app').find('p>input');
                inputParent.prop('checked', 'checked');
            } else {
            }

        });
    });
    //-->
</script>
<style type="text/css">
    .panel dl{overflow: hidden;}
    .panel dl dt {display: block;background-color: #f5f5f5;border-bottom: 1px none;padding: 10px 8px;}
    .panel  dl dd {float: left;padding: 8px;}
    .panel dl dd a{color: blue;}
    .panel dl dd a:hover{color: #ff0000; background-color: #ffffff;}
</style>
<div class="admin">
    <div class="tab panel dux-box admin-panel">
        <form action="" method="post" id="myform" name="myform">
            <div class="panel dux-box">
                <foreach name='node' item='app'>
                    <div class="app">
                        <p><input type="checkbox" name="access[]" value="{$app.id}_{$app.level}" level="1" <if condition="$app['access']">checked="checked"</if>/> <strong>{$app.title}</strong></p>
                        <foreach name = "app.child" item='action'>
                            <dl>
                                <dt><input type="checkbox" name="access[]" value="{$action.id}_{$action.level}" level="2" <if condition="$action['access']">checked="checked"</if>/> <strong>{$action.title}</strong></dt>
                                <foreach name = "action.child" item='method'>
                                    <dd><input type="checkbox" name="access[]" value="{$method.id}_{$method.level}" level="3" <if condition="$method['access']">checked="checked"</if>/> <span>{$method.title}</span></dd>
                                </foreach>
                            </dl>
                        </foreach>
                    </div>
                </foreach>
            </div>
            <div class="panel-foot">
                <div class="form-button">
                    <input type="hidden" name="rid" value="{$rid}" />
                    <button class="button bg-main" type="submit">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $('#myform').layer({});
</script>